#include <stdio.h>
#include <stdlib.h>

#define FLAG_A	0x00000001
#define FLAG_B	0x00000002
#define FLAG_C	0x00000004
#define FLAG_D	0x00000008
#define FLAG_E	0x00000010

#define setflag(x, y) ((x) = ((x) | (y)))
#define clrflag(x, y) ((x) = ((x) & ~(y)))
#define testflag(x, y) ((x) & (y))

#define CHARTOINT(a, b, c, d) ((((a) & 0xFF) << 24) | (((a) & 0xFF) << 16) | (((c) & 0xFF) << 8) | (((d) & 0xFF)))

int main() {
	int i = 0x00 & 0xFF;
	setflag(i, FLAG_A);
	setflag(i, FLAG_C);
	setflag(i, FLAG_D);
	setflag(i, FLAG_E);

	printf("\33[32m [MARCO][%d]---[%08x]---\33[0m\n", __LINE__, i); 
	printf("\33[32m [MARCO][%d]---[%d]---\33[0m\n", __LINE__, testflag(i, FLAG_D)); 
	printf("\33[32m [MARCO][%d]---[%d]---\33[0m\n", __LINE__, testflag(i, FLAG_B)); 
	printf("\33[32m [MARCO][%d]---[%08x]---\33[0m\n", __LINE__, clrflag(i, FLAG_D)); 

	unsigned char a[4];
	a[0] = 0x01 & 0xFF;
	a[1] = 0x01 & 0xFF;
	a[2] = 0x01 & 0xFF;
	a[3] = 0x01 & 0xFF;
	unsigned int b = CHARTOINT(a[0], a[1], a[2], a[3]);
	printf("\33[32m [MARCO][%d]---[%08x]-[%d]--\33[0m\n", __LINE__, b, b); 
	return 0;
}
